﻿Public Class ObjektUsermenue
    Inherits ObjektFormMenue
    Enum UserMenue
        Units
    End Enum
    Dim Mode As UserMenue = UserMenue.Units

    Public UnitCounterBox As New List(Of ObjektEinheitenUserData)
    Public Sub New()
        MyBase.New(New ObjektButton() {}, Nothing, New ObjektNumericUpDown() {}, Nothing, New ObjektValueSchieber() {}, New ObjektMultiValue() {}, New ObjektCheckBox() {})
        If DataSettings.Verhaeltnis = Hauptmenue.Breitbild Then
            Objektverwalter.LoadHintergrund(DataSettings.Resourcenpfad + "Backgrounds\HM1280a800.bmp")
        Else
            Objektverwalter.LoadHintergrund(DataSettings.Resourcenpfad + "Backgrounds\HM800a600.bmp")
        End If



        ChangeMode()
    End Sub

    Public Sub ChangeMode()
        Objekt2D.Reset()
        UnitCounterBox.Clear()
        Dim P As New ObjektPanel2D(New Rectangle(0, 0, Hauptmenue.Rechteck.Width, Hauptmenue.Rechteck.Height - 60), New PointF, 1, False)

        Select Case Mode
            Case UserMenue.Units
                Dim YMax As Integer = Math.DivRem(P.Rechteck.Height, Hauptmenue.Feldbreite + 4, 0)
                NeuLabel(DataSettings.BildschirmBreite / 2 - 60, 5, New String() {"Gebaute \ Zerstörte Einheiten"}, New PointF(0.5, 0), P)
                Dim Ready As Boolean = False
                Dim X As Integer = 0
                Dim I As Integer = 0
                While Not Ready

                    For Y = 1 To YMax - 1
                        UnitCounterBox.Add(New ObjektEinheitenUserData(New Point(DataSettings.BildschirmBreite / 2 - (X * 100 + 50), Y * (Hauptmenue.Feldbreite + 4) + 2), New Point, Objektverwalter.AlleEinheiten(I).EinheitenID, True, Hauptmenue.AlleFarbtabellen(0), P))
                        I += 1
                        If I >= Objektverwalter.AlleEinheiten.Length Then
                            I = 0
                            Ready = True
                            Exit For
                        End If
                    Next
                    X += 1
                End While
                Ready = False
                X = 0
                While Not Ready

                    For Y = 1 To YMax - 1
                        UnitCounterBox.Add(New ObjektEinheitenUserData(New Point(X * 100 + 50 + DataSettings.BildschirmBreite / 2, Y * (Hauptmenue.Feldbreite + 4) + 2), New Point, Objektverwalter.AlleEinheiten(I).EinheitenID, False, Hauptmenue.AlleFarbtabellen(4), P))
                        I += 1
                        If I >= Objektverwalter.AlleEinheiten.Length Then
                            I = 0
                            Ready = True
                            Exit For
                        End If
                    Next
                    X += 1
                End While
        End Select

        NeuButton(20, DataSettings.BildschirmHoehe - 40, DataSettings.Resourcenpfad + "Objects\Button.png", "Zurueck", New PointF(0, 1), , , , )
    End Sub

    Public Overrides Sub ChangeWindowSize(ByVal PosChange As System.Drawing.Point)
        MyBase.ChangeWindowSizeObjekte(PosChange)
    End Sub

    Public Overrides Sub Frame()

    End Sub

    Public Overrides Sub IniMenue()

    End Sub

    Public Overrides Sub KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
        If Not KeyDownObjekte(sender, e) Then
            Select Case e.KeyCode
                Case Keys.Escape
                    ButtonGeklicktLinks("Zurueck")
                Case Else
            End Select
        End If
    End Sub

    Public Overrides Sub KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)

    End Sub

    Public Overrides Sub Malen()
        MyBase.ObjekteMalen()

        For I = 0 To UnitCounterBox.Count - 1
            UnitCounterBox(I).Malen()
        Next
    End Sub

    Public Overrides Sub MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        checkMouseDownObjekte(ObjektMaus.XKoordinate, ObjektMaus.YKoordinate)
    End Sub

    Public Overrides Sub MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        MouseMoveObjekte(e.X, e.Y)
    End Sub

    Public Overrides Sub MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        Select Case e.Button
            Case Windows.Forms.MouseButtons.Left
                ButtonGeklicktLinks(checkMouseUPObjekte(ObjektMaus.XKoordinate, ObjektMaus.YKoordinate))
        End Select
    End Sub
    Public Sub ButtonGeklicktLinks(ByVal Effekt As String)
        If Effekt = Nothing Then
            Exit Sub
        End If
        Select Case Effekt.ToLower
            Case "zurueck"
                Hauptmenue.Ini(Hauptmenue.Formmodi.Hauptmenue)
        End Select
    End Sub

    Public Overrides Sub MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)

    End Sub

    Public Overrides Sub SetMausBild()
        ObjektMaus.Zustand = ObjektMaus.Zustaende.Menue
    End Sub

    Public Overrides Sub SprachEingabe(ByVal Eingabe As String)

    End Sub
End Class
